package com.lhj.springboot3.core.listener;

import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.time.Duration;

/**
 * @Description
 * @Author lhj
 * @Date 2024/6/25 22:14
 */
public class MyAppListener implements SpringApplicationRunListener {

    @Override
    public void starting(ConfigurableBootstrapContext bootstrapContext) {
        System.out.println("========引导上下文容器开始启动========");
    }

    @Override
    public void environmentPrepared(ConfigurableBootstrapContext bootstrapContext, ConfigurableEnvironment environment) {
        System.out.println("========开始引导上下文环境========");
    }

    @Override
    public void contextPrepared(ConfigurableApplicationContext context) {
        System.out.println("========上下文准备完成========");
    }

    @Override
    public void contextLoaded(ConfigurableApplicationContext context) {
        System.out.println("========上下文加载完成========");
    }

    @Override
    public void started(ConfigurableApplicationContext context, Duration timeTaken) {
        System.out.println("========应用程序启动完成========");
    }

    @Override
    public void ready(ConfigurableApplicationContext context, Duration timeTaken) {
        System.out.println("========应用程序准备就绪========");
    }

    @Override
    public void failed(ConfigurableApplicationContext context, Throwable exception) {
        System.out.println("========应用程序启动出现错误========");
    }
}
